<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
.tongrong-box {
	padding-top:20px;
}
</style>
<div class="tongrong-box" style="width:680px;">
	<form class="login-box-form J-ajaxForm" action="/member/operate/option/save/" method="post" autocomplete="off">
	<div class="tongrong-box-main">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0">
        	<tr>
            	<td width="70px" height="30">真实姓名：</td>
                <td>
                	<input name="u_realname" type="text" id="u_realname" size="35" value="<?php echo $this->data['u_realname'];?>" />                </td>
                <td width="70px" height="30">用户名：</td>
                <td>
                	<input name="u_name" type="text" id="u_name" size="35" value="<?php echo $this->data['u_name'];?>" />                </td>
            </tr>
            <tr>
            	<td width="70px" height="30px">部门类型：</td>
                <td colspan="3">
                	<label>
                    	<input type="radio" name="radiobox" style="vertical-align:sub" <?php echo $this->data['u_dp_type'] == 'dp' ? 'checked' : '';?> value="dp" /> 内部部门                    </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label>
                    	<input type="radio" name="radiobox" style="vertical-align:sub" <?php echo $this->data['u_dp_type'] == 'dot' || $this->data['u_dp_type'] == 'rg' ? 'checked' : '';?> value="dot" /> 业务网点                    </label>                </td>
            </tr>
            
            <script type="text/javascript">
				window.BANK = [];
				window.uDpType = '<?php echo $this->data['u_dp_regroup']?>';
            	$(document).ready(function(e) {
					//默认加载选择部门
					var dpVal = '<?php $this->data['u_dp_type'] == 'dp' ? 'dp' : ($this->data['u_dp_type'] == 'dot' ? 'dot' : 'rg');?>';
					getShowtype(dpVal);
					
					//选择事件
                    $('input[name="radiobox"]').on('change',function(){
						var val = $(this).val();
						getShowtype(val);
							
					});
					
					//选择部门或者网点
					$('.J-u-dp-select').on('change',function(){
						var val = $(this).val();
						if(val == '0'){
							Ext.Msg.alert('提示','请选择');
							return false;	
						}
						var bankArr = BANK[val];
						getBank(bankArr);
						
						$.post('/public/ajax/option/jobnum/',{'dp_code':val},function(data){
							$("#u_code").val(data);	
						},'html');	
					});
					
					//
					if(uDpType !=''){
						var bankArr = BANK[uDpType];
						var selectBank = '<?php echo $this->data['u_bank'];?>';
						getBank(bankArr);	
					}
					
                });
				
				//根据部门类型显示部门
				function getShowtype(val){
					BANK = [];
					$(".J-u-dp-select").html('<option>加载中...</option>');
					if(val == 'dp'){
						$(".J-u-dp-txt").text('选择部门：');
						$.post('/public/ajax/option/dpinfo/',function(data){
							if(data){
								var html='<option value="0">请选择</option>';
								for(var i =0; i < data.length; i++){
									if(uDpType == data[i]['value']){
										html+='<option selected value="'+data[i]['value']+'">'+data[i]['dp_name']+'</option>';
									}else{
										html+='<option value="'+data[i]['value']+'">'+data[i]['dp_name']+'</option>';
									}
									BANK[data[i]['value']] = eval(data[i]['bank_list']);	
								}	
								$(".J-u-dp-select").html(html);
							}
							
						},'json');	
					}else{
						
						$(".J-u-dp-txt").text('选择网点：');
						$.post('/public/ajax/option/region/',function(data){
							if(data){
								var html='<option value="0">请选择</option>';
								for(var i =0; i < data.length; i++){
									html+='<option value="'+data[i]['rg_id']+'">'+data[i]['rg_name']+'</option>';
									
									var branch = data[i]['branch'];
									for(var j =0; j < branch.length; j++){
										if(uDpType == branch[j]['value']){
											html+='<option selected value="'+branch[j]['value']+'">&nbsp;|---'+branch[j]['br_name']+'</option>';
										}else{
											html+='<option value="'+branch[j]['value']+'">&nbsp;|---'+branch[j]['br_name']+'</option>';
										}
											
										BANK[branch[j]['value']] = eval(branch[j]['bank_list']);
									}
										
								}	
								$(".J-u-dp-select").html(html);
							}
							
						},'json');
					}	
				}
				
				//关联银行
				/**
				* bank 银行数组
				* chkid 选中数组
				**/
				function getBank(bank,chkid){
					var html='';
					var chkid = '2,3';
					var chkArr = chkid.split(',');
					if(bank){
						for(var v =0; v < bank.length; v++){
							html+='<label>';
							if(chkArr.indexOf(bank[v]['bk_id']) > -1){
								html+='	<input checked type="checkbox" class="child_bank" rel="bank" name="u_bank[]" value="'+bank[v]['bk_id']+'" /> '+bank[v]['bk_name']+'';
							}else{
								html+='	<input type="checkbox" class="child_bank" rel="bank" name="u_bank[]" value="'+bank[v]['bk_id']+'" /> '+bank[v]['bk_name']+'';
							}
							html+='</label>';
						}	
					}
					
					$(".J-bank-list").html(html);
						
				}
            </script>
            
            <tr>
            	<td width="70px" height="30" class="J-u-dp-txt">选择部门：</td>
                <td>
                	<select class="J-u-dp-select" name="u_dp_id">
                    	<option value="0">请选择</option>
                    </select>                </td>
                <td width="70px" height="30">手机号：</td>
                <td>
                	<input name="u_mobile" type="text" id="u_mobile" size="35" value="<?php echo $this->data['u_mobile'];?>" />                </td>
            </tr>
            <tr>
            	<td width="70px" height="30px">工　　号：</td>
                <td colspan="3">
                	<input type="text" name="u_code" readonly id="u_code" value="<?php echo $this->data['u_code'];?>" style="background: rgb(230, 230, 230);" />                </td>
            </tr>
            <tr>
            	<td width="70px" height="30px">权限等级：</td>
                <td>
                	<select name="u_scope">
                    	<option value="">请选择</option>
                        <option <?php echo $this->data['u_scope'] == '用户级' ? 'selected':'';?> value="用户级">用户级</option>
                        <option <?php echo $this->data['u_scope'] == '部门级' ? 'selected':'';?> value="部门级">部门级</option>
                        <option <?php echo $this->data['u_scope'] == '单位级' ? 'selected':'';?> value="单位级">单位级</option>
                    </select>
				</td>
            </tr>
            <tr>
            	<td width="70px" height="30">岗位职责：</td>
                <td>
                	<input name="u_job" type="text" id="u_job" size="35" value="<?php echo $this->data['u_job'];?>" />
				</td>
                <td width="70px" height="30">权限角色：</td>
                <td>
                	<select name="u_role" class="J-quanxianjs">
                    	<option value="">请选择</option>
                    </select>                </td>
            </tr>
            <script type="text/javascript">
            	$(document).ready(function(e) {
                    $.post('/public/ajax/option/role/',function(data){
						var html='<option value="">请选择</option>';
						var oldVal = '<?php echo $this->data['u_role'];?>';
						for(var i =0; i< data.length; i++){
							if(oldVal == data[i]['r_id']){
								html+='<option selected value="'+data[i]['r_id']+'">'+data[i]['r_name']+'</option>';	
							}else{
								html+='<option value="'+data[i]['r_id']+'">'+data[i]['r_name']+'</option>';		
							}
							
						}
						$(".J-quanxianjs").html(html);	
					},'json');
                });
            </script>
            
            <tr>
            	<td width="70px" height="30px">地　　址：</td>
                <td colspan="3">
                	<input type="text" name="u_addr" id="u_addr" value="<?php echo $this->data['u_addr'];?>" style="width: 451px;" />                </td>
            </tr>
            <tr>
            	<td width="70px" height="30">身份证号：</td>
                <td>
                	<input name="u_idcard" type="text" id="u_idcard" size="35" value="<?php echo $this->data['u_idcard'];?>" />                </td>
                <td width="70px" height="30">性　　别：</td>
                <td>
                	<select name="u_sex">
                    	<option value="">请选择</option>
                        <option <?php echo $this->data['u_sex'] == '男' ? 'selected' : '';?> value="男">男</option>
                        <option <?php echo $this->data['u_sex'] == '女' ? 'selected' : '';?> value="女">女</option>
                    </select>                </td>
            </tr>
            <tr>
            	<td width="70px" height="30">出生年月：</td>
                <td>
                	<input name="u_birthday" type="text" id="u_birthday" onClick="WdatePicker()" size="35" value="<?php echo $this->data['u_birthday'];?>" />                </td>
                <td width="70px" height="30">文化程度：</td>
                <td>
                	<select name="u_culture" class="J-wenhuacd">
                    	<option value="">请选择</option>
                    </select>                </td>
            </tr>
            <script type="text/javascript">
            	$(document).ready(function(e) {
					$(".J-wenhuacd").dyhlSelect({'type':'学历'});
                });
            </script>
            <tr>
            	<td width="70px" height="30">电　　话：</td>
                <td>
                	<input name="u_tel" type="text" id="u_tel" size="35" value="<?php echo $this->data['u_tel'];?>" />                </td>
                <td width="70px" height="30">QQ：</td>
                <td>
                	<input name="u_qq" type="text" id="u_qq" size="35" value="<?php echo $this->data['u_qq'];?>" />                </td>
            </tr>
            <tr>
            	<td height="40px" valign="top" >授权银行：</td>
                <td colspan="3">
                	<style type="text/css">
                    	/* 选择银行列表 */
						.bank-list {
							max-height:250px; overflow:auto; margin-bottom:10px; font-size:12px; border:1px solid #e1e1e1; padding:10px 15px; width:419px;height: 100px;overflow-y: scroll;overflow-x: hidden;
						}
						
						.bank-list dt, .bank-list dd{
							padding:3px 0;
						}
						
						.bank-list dd label {
							display:block;
						}
						
						.bank-list dt input,.bank-list dd input {
							vertical-align:sub;
						}
                    </style>
                    
                    <dl class="bank-list">
                    	<dt><input type="checkbox" class="checkAll" rel="bank" value="1" /> 全选</dt>
                        <dd class="J-bank-list">                        </dd>
                    </dl>                </td>
            </tr>
            <tr>
            	<td width="70px" height="30px">备　　注：</td>
                <td colspan="3">
                	<textarea name="u_info" id="u_info" style="width: 451px; height: 95px;"><?php echo $this->data['u_info'];?></textarea>                </td>
            </tr>
            <tr>
            	<td width="70px" height="30px">加入时间：</td>
                <td colspan="3">
                	<input type="text" name="u_addtime" id="u_addtime" readonly value="<?php echo $this->data['u_addtime'];?>" style="background: rgb(230, 230, 230);" />                </td>
            </tr>
        </table>
    </div>
    <div class="luru-box-btn mt50" style="margin-right:100px">
		<input type="hidden" name="option" value="save" />
		<input type="hidden" name="id" value="<?php echo $this->id;?>" />
    	<input class="btn-submit-blue fn-left mr15 J-submit" type="submit" value="提交" />
        <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
    </div>
	</form>
</div>

<script>
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
	});
	
	$(document).ready(function(e) {
		//全选
		$(document).on("click", ".checkAll", function (e) {
			var child = $(this).attr('rel');
			$(".child_" + child).prop('checked', $(this).prop("checked"));
		});

        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:submitChk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
					Ext.getBody().unmask();
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					Ext.getBody().unmask();
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.parent.App.store.reload();
							var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
							parent.Ext.getCmp(winElement.id).close();
						});
						
					}else{
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
    });
	
	//表单验证
	function submitChk(){
		if($("#u_realname").val() == ''){
			Ext.Msg.alert('提示','真实姓名不能为空!');	
			return false;
		}
		
		if($("#u_name").val() == ''){
			Ext.Msg.alert('提示','用户名不能为空!');	
			return false;
		}
		
		if($("#u_mobile").val() == ''){
			Ext.Msg.alert('提示','手机号不能为空!');	
			return false;
		}
		
		if($("#u_mobile").val() == ''){
			Ext.Msg.alert('提示','手机号不能为空!');	
			return false;
		}
		
		$(".J-submit").prop('disabled',true);
		Ext.getBody().mask("数据提交中，请稍等");
			
	}
	
</script>

<?php include $this->Render('footer.php'); ?>